﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using JavaSubstitutes;

namespace Sprites
{
	public class WinScene : Scene
	{
		private MarioComponent component;
		private int tickCount;
		private String scrollMessage = "Thank you for saving me, Mario!";

		public WinScene(MarioComponent component)
		{
			this.component = component;
		}

		public override void init()
		{
		}

		//public override void render(Graphics wbmp, double alpha)
		public override void render(WriteableBitmap wbmp, double alpha)
		{
			wbmp.setColor(ColorExtensions.decode("#8080a0"));
			//dest.fillRect(0, 0, 320, 240);
			wbmp.drawImage(Art.endScene[tickCount / 24 % 2, 0], 160 - 48, 100 - 48);
			//drawString(dest, scrollMessage, 160 - scrollMessage.Length() * 4, 160, 0);
		}

		private void drawString(Graphics g, String text, int x, int y, int c)
		{
			char[] ch = text.toCharArray();
			for (int i = 0; i < ch.Length; i++)
			{
				g.drawImage(Art.font[ch[i] - 32, c], x + i * 8, y, null);
			}
		}

		private bool wasDown = true;
		public override void tick()
		{
			tickCount++;
			if (!wasDown && keys[Mario.KEY_JUMP])
			{
				component.ShowTitleScreen();
			}
			if (keys[Mario.KEY_JUMP])
			{
				wasDown = false;
			}
		}

		public double getX(double alpha)
		{
			return 0;
		}

		public double getY(double alpha)
		{
			return 0;
		}
	}

}